------------------------------------------------------------------------------------------------------------------------------------------------
      name:  <unnamed>
       log:  C:\Users\mgolder\Dropbox\campaign_sentiment_paper\replication\data_analysis\figure1_appendix.log
  log type:  text
 opened on:  14 Jan 2019, 15:59:05

. 
. #delimit ;
delimiter now ;
. *     ***************************************************************** *;
. *     ***************************************************************** *;
. *       File-Name:      figure1_appendix.do                             *;
. *       Date:           January 14, 2019                                *;
. *       Author:         MRG/CC                                          *;
. *       Purpose:        Produce Figure 1 in Online appendix for It's    *;
. *                       Not Only What You Say, It's Also How You Say    *;
. *                       It: The Strategic Use Of Campaign Sentiment.    *;
. *                       Journal of Politics. Forthcoming.               *;
. *           Input File:     sentiment.dta                                   *;
. *       Output File:    figure1_appendix.log                            *;
. *       Data Output:    none                                            *;
.              *       Previous file:  sentiment.dta                                   *;
. *       Machine:        desktop/laptop                                                  *;
. *     ****************************************************************  *;
. *     ****************************************************************  *;
. *     ****************************************************************  *;
. *        Load data                                                      *;
. *     ****************************************************************  *;
. use "C:\Users\mgolder\Dropbox\campaign_sentiment_paper\replication\data_analysis\sentiment.dta", clear;

. set more off;

. *     ****************************************************************  *;
. *       Declare data to be panel, where the panel is based on language  *;
. *     ****************************************************************  *;
. xtset language;
       panel variable:  language (unbalanced)

. xtsum positive_sentiment;

Variable         |      Mean   Std. Dev.       Min        Max |    Observations
-----------------+--------------------------------------------+----------------
positi~t overall |  1.696912   1.446166       -.68        7.6 |     N =     421
         between |              1.34797   .4018627     4.3828 |     n =       7
         within  |             .7198334  -1.565888   4.914112 | T-bar = 60.1429

. *     ****************************************************************  *;
. *       Generate additional variables that we will need for our         *;
. *       analysis.                                                       *;
. *     ****************************************************************  *;
. gen incumbent_inflation_l = incumbent*inflation_l;
(21 missing values generated)

. label var incumbent_inflation "incumbent*inflation_l";

. gen incumbent_unemployment_l = incumbent*unemployment_l;
(7 missing values generated)

. label var incumbent_unemployment_l "incumbent*unemployment_l";

. gen incumbent_pm = incumbent*pm;

. label var incumbent_pm "incumbent*pm";

. gen incumbent_fm = incumbent*fm;

. label var incumbent_fm "incumbent*fm";

. gen left_right2=left_right*left_right;
(39 missing values generated)

. label var left_right2 "left_right*left_right";

. gen extremist = 0;

. replace extremist=1 if family_id ==14 | family_id==40;
(87 real changes made)

. replace extremist = . if family_id==.;
(9 real changes made, 9 to missing)

. label var extremist "1 if communist/socialist or far right, 0 otherwise";

. gen extremist2 = 0;

. replace extremist2=1 if family_id ==14 | family_id==40 | family_id==19;
(124 real changes made)

. replace extremist2 = . if family_id==.;
(9 real changes made, 9 to missing)

. label var extremist2 "1 if communist/socialist, far right, or greens, 0 otherwise";

. gen extremist_inflation_l=extremist*inflation_l;
(30 missing values generated)

. label var extremist_inflation "extremist*inflation_l";

. gen extremist_unemployment_l=extremist*unemployment_l;
(16 missing values generated)

. label var extremist_unemployment_l "extremist*unemployment_l";

. tabulate language, gen(l);

   language |      Freq.     Percent        Cum.
------------+-----------------------------------
      Dutch |        102       24.23       24.23
    English |         85       20.19       44.42
     French |         36        8.55       52.97
     German |         46       10.93       63.90
    Italian |         54       12.83       76.72
 Portuguese |         50       11.88       88.60
    Spanish |         48       11.40      100.00
------------+-----------------------------------
      Total |        421      100.00

. sum positive_emotion negative_emotion positive_sentiment;

    Variable |        Obs        Mean    Std. Dev.       Min        Max
-------------+---------------------------------------------------------
positive_e~n |        421     3.02133    1.908511        .64       9.62
negative_e~n |        421    1.324418    .7893864          0       5.22
positive_s~t |        421    1.696912    1.446166       -.68        7.6

. *     ****************************************************************  *;
. *      Change graph scheme                                                  *;
. *     ****************************************************************  *;
. *ssc install scheme-burd, replace;
. *     ****************************************************************  *;
. *     ****************************************************************  *;
. *       Produce Figure 1 in the Appendix                                *;
. *     ****************************************************************  *;
. *     ****************************************************************  *;
. *     ****************************************************************  *;
. *       Panel A                                                         *;
. *     ****************************************************************  *;
. histogram positive_emotion, xtitle("Positive Words Scores") scheme(burd);
(bin=20, start=.63999999, width=.44899999)

. graph export "C:\Users\mgolder\Dropbox\campaign_sentiment_paper\fig1a_appendix.pdf", replace;
(file C:\Users\mgolder\Dropbox\campaign_sentiment_paper\fig1a_appendix.pdf written in PDF format)

. *     ****************************************************************  *;
. *       Panel B                                                         *;
. *     ****************************************************************  *;
. histogram negative_emotion, xtitle("Negative Words Scores") scheme(burd);
(bin=20, start=0, width=.26099999)

. graph export "C:\Users\mgolder\Dropbox\campaign_sentiment_paper\fig1b_appendix.pdf", replace;
(file C:\Users\mgolder\Dropbox\campaign_sentiment_paper\fig1b_appendix.pdf written in PDF format)

. *     ****************************************************************  *;
. *       Panel C                                                         *;
. *     ****************************************************************  *;
. histogram positive_sentiment, xtitle("Positive Sentiment") scheme(burd);
(bin=20, start=-.68000001, width=.414)

. graph export "C:\Users\mgolder\Dropbox\campaign_sentiment_paper\fig1c_appendix.pdf", replace;
(file C:\Users\mgolder\Dropbox\campaign_sentiment_paper\fig1c_appendix.pdf written in PDF format)

.    *     ****************************************************************  *;
. *       Replication complete                                            *;
. *     ****************************************************************  *;
. log close;
      name:  <unnamed>
       log:  C:\Users\mgolder\Dropbox\campaign_sentiment_paper\replication\data_analysis\figure1_appendix.log
  log type:  text
 closed on:  14 Jan 2019, 15:59:06
------------------------------------------------------------------------------------------------------------------------------------------------
